#!/usr/bin/env node

var fs = require('fs');
var path = require('path');

var indexScript = fs.readdirSync(path.resolve(__dirname, './'))
  .filter((item) => item.includes('.png') || item.includes('.svg'))
  .reduce((script, item) => 
    script = script + '\n' + `  ${camelCase(item)}: require('./${item}'),`
  , "export default {")
  
indexScript = indexScript + '\n};'

fs.writeFileSync(
  path.resolve(__dirname, 'index.js'),
  indexScript
);

function camelCase(item) {
  item = item.split(/\.+/g).shift();
  return item.replace(/[-_]+\S/g, (s) => s.slice(-1).toUpperCase());
}